using System;
using System.Reflection;

namespace Common.Core.Objects
{
	public class DefaultPropertyValueAttribute : DefaultPropertyValueAttributeBase
	{
		readonly string value;

		public DefaultPropertyValueAttribute( string propertyName, object value ) : base( propertyName )
		{
			Guard.IsNotNullOrEmpty( propertyName, "propertyName" );
			Guard.IsNotNull( value, "value" );
			this.value = value.ToString();
		}

		public Type TypeConverterType { get; set; }

		protected internal override object GetValue( PropertyInfo property )
		{
			object result = ConversionHelper.CheckForConversion( value, property, TypeConverterType );
			return result;
		}
	}
}